﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;


using FXnaEngine.Interfaces;

using FXnaEngine.Components;

using FXnaEngine.Physics;

using FXnaEngine.Graphics;




namespace FXnaEngine
{

    /// <summary>
    /// 设计用于便宜调用basiceffect
    /// </summary>
    public class FBasicSE
    {


        public FBasicSE()
        {

            basicEffect = new BasicEffect(FEngineState.Device);
 
        }


        BasicEffect basicEffect;

        /// <summary>
        /// 外围提供一个公共的绘制Effect，在实体自己没有准备的情况下
        /// </summary>
        public BasicEffect BasicEffect
        {
            get { return basicEffect; }

        }


        public virtual void SetParameters(FMaterial material, Matrix world)
        {
            basicEffect.Alpha = material.Alpha;

            basicEffect.DiffuseColor = Vector3Helper.GetVector3(material.Diffuse);
            basicEffect.SpecularColor = Vector3Helper.GetVector3(material.Specular);
            basicEffect.EmissiveColor = Vector3Helper.GetVector3(material.Emissive);

            basicEffect.SpecularPower = material.SpecularPower;
            basicEffect.TextureEnabled = material.HasTexture;
            basicEffect.Texture = material.Texture;




            basicEffect.World = world;

            basicEffect.View = FEngineState.ViewMatrix;
            basicEffect.Projection = FEngineState.ProjectionMatrix;



            //暂时使用默认灯光

            basicEffect.EnableDefaultLighting();




        }


    }


}
